package com.zks.example.拆包粘包;

import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class MyServer {
    public static void main(String[] args) {
        ServerSocket serverSocket;
        try {
            serverSocket = new ServerSocket(8089);
            Socket socket = serverSocket.accept();
            while (true){
               byte[] buffer=new byte[1024];
                StringBuffer receivBuffer = new StringBuffer();
                InputStream inputStream = socket.getInputStream();
                int count=inputStream.read(buffer);
                if(count>0){
                    receivBuffer.append(new String(buffer,0,count));
                    System.out.println("receive data from client:"+receivBuffer.toString());
                }
                if(count==-1){
                    System.out.println("----------------0000000-------------");
                }

            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
